var a = getApp();

Page({
    data: {
        category: [],
        threshold: 4,
        message: !1,
        active: 0,
        page: 1
    },
    onLoad: function(a) {},
    goRecord: function(a) {
        wx.navigateTo({
            url: "/packageE/video_question/videoRecord/videoRecord"
        });
    },
    tapSwiper: function(a) {
        console.log(a);
        var t = a.currentTarget.dataset.url;
        try {
            wx.navigateTo({
                url: t
            });
        } catch (a) {
            console.log(a);
        }
    },
    goAnswer: function() {
        2 == this.data.info.application_audit_status ? wx.navigateTo({
            url: "/packageE/video_question/answer/answer"
        }) : wx.navigateTo({
            url: "/packageE/video_question/apply/apply"
        });
    },
    onClickLeft: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    timeOr: function(t) {
        var e = this;
        if (console.log("...sasdasdasd scroll触底触发"), !(this.data.current_page >= this.data.last_page)) {
            var n = e.data.page + 1;
            e.setData({
                page: n
            });
            var o = a.getNetAddresss("plugin.agent-qa.api.message.get-list");
            a._postNetWork({
                url: o,
                data: {
                    page: e.data.page
                },
                success: function(a) {
                    var t = a.data;
                    1 == t.result ? (console.log(t), e.setData({
                        current_page: t.data.current_page,
                        last_page: t.data.last_page,
                        messageList: e.data.messageList.concat(t.data.data)
                    })) : wx.showToast({
                        title: t.msg,
                        icon: "none"
                    });
                },
                fail: function(a) {
                    wx.showToast({
                        title: a.msg,
                        icon: "none"
                    });
                }
            });
        }
    },
    onClickRight: function() {
        var t = this, e = a.getNetAddresss("plugin.agent-qa.api.message.get-list");
        a._postNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (console.log(e), t.setData({
                    message: !0,
                    current_page: e.data.current_page,
                    last_page: e.data.last_page,
                    messageList: e.data.data
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            }
        });
    },
    onClose: function() {
        this.setData({
            message: !1
        });
    },
    chunk: function(a, t) {
        for (var e = [], n = 0, o = a.length; n < o; n += t) e.push(a.slice(n, n + t));
        return e;
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.agent-qa.api.index.index");
        a._postNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    console.log(e), t.setData({
                        info: e.data,
                        category: e.data.button_list,
                        unread_message_count: e.data.unread_message_count
                    });
                    var n = t.chunk(t.data.category, 10);
                    t.setData({
                        category_10: n
                    }), wx.setNavigationBarTitle({
                        title: e.data.name
                    });
                } else wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            }
        });
    },
    onClick: function(a) {
        var t = a.detail.index, e = a.detail.title;
        console.log(t, e), this.setData({
            active: t
        });
    },
    toWatch: function(a) {
        console.log(a);
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageE/video_question/watch/watch?id=" + t
        });
    }
});